﻿Imports Microsoft.VisualBasic
Imports System.Data

<System.ComponentModel.DataObjectAttribute(True)> _
Public Class BLL_ManageTrainingCourse_SearchTrainingCourseControl

    Public Sub New()
        ' 
        ' TODO: 在此加入建構函式的程式碼 
        ' 
    End Sub

    'SELECT 
    <System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.[Select])> _
    Public Function BLL_Select(ByVal GroupId As Integer, ByVal CourseType As String) As DataTable

        Dim sql As New MyStringBuilder
        Dim dat As New clsData

        sql.AppendFormat("SELECT A.*, B.Text as CourseTypeText ")
        sql.AppendFormat("FROM TrainingCourse A ")
        sql.AppendFormat("inner join CodeMapping B on TableName='TrainingCourseGroup' and ColumnName='GroupType' and A.CourseType = B.Value ")
        sql.AppendFormat("left join TrainingCourseGroupMapping C on A.Id=C.CourseId and C.GroupId ={0} ", GroupId)
        sql.AppendFormat("WHERE C.CourseId Is null ")
        sql.AppendFormat("AND (A.CourseType='{0}' or '{0}'='0') ", CourseType)
        Return dat.GetData(sql)

    End Function

End Class
